import { request } from "@/utils/request.js";

// 获取我的用药提醒列表
const getMyMedicationList = (params) => {
  return request({
    url: "api/mr/getMRList",
    method: "GET",
  });
};

// 获取药品列表
const getDrugList = (params) => {
  return request({
    url: "api/mr/getMList",
    method: "GET",
    data: params,
  });
};

// 获取药品分类列表
const getDrugTypeList = (params) => {
  return request({
    url: "api/mr/getMCList",
    method: "GET",
    data: params,
  });
};

// 获取药品已设置提醒数量
const getMedicationCount = (params) => {
  return request({
    url: "api/mr/getMMRCount",
    method: "GET",
    data: params,
  });
};

// 获取用药频次
const getMedicationFrequencyList = (params) => {
  return request({
    url: "api/mr/getMF",
    method: "GET",
    data: params,
  });
};

// 获取模板id
const getMedicationTemplateId = (params) => {
  return request({
    url: "api/mr/templateId",
    method: "GET",
    data: params,
  });
};

// 用户订阅消息
const subTemplate = (params) => {
  return request({
    url: "api/wxapp/tplSub",
    method: "POST",
    data: params,
  });
};

// 新增|编辑用药提醒
const saveMedication = (params) => {
  return request({
    url: "api/mr/saveMR",
    method: "POST",
    data: params,
  });
};

// 用药提醒状态改变
const changeMedicationStatus = (params) => {
  return request({
    url: "api/mr/changeMRStatus",
    method: "POST",
    data: params,
  });
};

// 删除用药提醒
const deleteMedication = (params) => {
  return request({
    url: "api/mr/delMR",
    method: "POST",
    data: params,
  });
};

// 我的已完成用药提醒
const getComplatedMedication = (params) => {
  return request({
    url: "api/mr/getCompletedMRList",
    method: "GET",
    data: params,
  },false);
};

// 获取用户下一次提醒的用药提醒任务
const getNextMedication = (params) => {
  return request({
    url: "api/mr/getNextMR",
    method: "GET",
    data: params,
  });
};

// 获取用户是否关注公众号
const getIsSubscribed = (params) => {
  return request(
    {
      url: "api/crm/getIsSubscribed",
      method: "GET",
      data: params,
    },
    false
  );
};

// 获取用户用药通知状态
const getNoticeStatus = (params) => {
  return request({
    url: "api/mr/getNoticeStatus",
    method: "GET",
    data: params,
  });
};

// 批量修改所有用药提醒状态
const changeAllMRStatus = (params) => {
  return request({
    url: "api/mr/changeAllMRStatus",
    method: "POST",
    data: params,
  });
};

module.exports = {
  getMyMedicationList,
  getDrugList,
  getDrugTypeList,
  getMedicationCount,
  getMedicationFrequencyList,
  getMedicationTemplateId,
  subTemplate,
  saveMedication,
  changeMedicationStatus,
  deleteMedication,
  getComplatedMedication,
  getNextMedication,
  getIsSubscribed,
  getNoticeStatus,
  changeAllMRStatus,
};
